﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using DevExpress.Skins;
using DevExpress.XtraTreeList.Nodes;
using DevExpress.XtraTreeList;
using DevExpress.Utils.Design;
using DevExpress.XtraSplashScreen;

namespace PRO_DOCS.DocumentManagementSystem.ADMIN.WIN.Configurations.Departments
{
    public partial class ucFolderStructureTree : BLL.WIN.Templates.DevxPermissionUserControlTemplate
    {
        [Browsable(false)]
        public PRO_DOCS.DAL.Database.ARCHIVE_DEPARTMENT CURRENT_SELECTED_ARCHIVE_DEPARTMENT
        {
            get;
            set;
        }

        private PRO_DOCS.DAL.Database.ARCHIVE_DEPARTMENTS_FOLDERS_STRUCTURE _cURRENT_SELECTED_ARCHIVE_DEPARTMENTS_FOLDERS_STRUCTURE;
        [Browsable(false)]
        public PRO_DOCS.DAL.Database.ARCHIVE_DEPARTMENTS_FOLDERS_STRUCTURE CURRENT_SELECTED_ARCHIVE_DEPARTMENTS_FOLDERS_STRUCTURE
        {
            get { return _cURRENT_SELECTED_ARCHIVE_DEPARTMENTS_FOLDERS_STRUCTURE; }
            set
            {
                _cURRENT_SELECTED_ARCHIVE_DEPARTMENTS_FOLDERS_STRUCTURE = value;

                LOAD_FOLDER_STRUCTURE_PERMISSIONS(value.ARCHIVE_DEPARTMENTS_FOLDERS_STRUCTURE_ID);
                //CURRENT_SELECTED_ARCHIVE_DEPARTMENT = _cURRENT_SELECTED_ARCHIVE_DEPARTMENTS_FOLDERS_STRUCTURE.ARCHIVE_DEPARTMENT;
            }
        }

        private void LOAD_FOLDER_STRUCTURE_PERMISSIONS(Guid folderStructreId)
        {
            //1. LOAD RERMITTED USER ROLES
            ucPermittedUserRoles1.LOAD_PERMITTED_USER_ROLES(Security.ucBaseSecurity.SecurityOptions.FolderStructureSecurity, 0, folderStructreId, 0);
            //2. LOAD DENIED USER ROLES
            ucDeniedUserRoles1.LOAD_DENIED_USER_ROLES(Security.ucBaseSecurity.SecurityOptions.FolderStructureSecurity, 0, folderStructreId);
            //3. LOAD PERMITTED USERS
            ucPermittedLoginUsers1.LOAD_PERMITTED_LOGIN_USERS(Security.ucBaseSecurity.SecurityOptions.FolderStructureSecurity, 0, folderStructreId, 0);
            //4. LOAD DENIED USERS 
            ucDeniedLoginUsers1.LOAD_DENIED_LOGIN_USERS(Security.ucBaseSecurity.SecurityOptions.FolderStructureSecurity, 0, folderStructreId, 0);

        }

        [Browsable(false)]
        public ApplicationStructureTypes CURRENT_SELECTED_ApplicationStructureType
        {
            get;
            set;
        }

        public FolderStructureViewModes CURRENT_SELECTED_VIEW_MODE
        {
            get;
            set;
        }
        public enum FolderStructureViewModes
        {
            MainForm = 0,
            FolderSelection
        }

        bool IS_FIRST_LOAD
        { get; set; }
        public ucFolderStructureTree()
        {
            InitializeComponent();
            IS_FIRST_LOAD = true;
            CURRENT_SELECTED_ARCHIVE_DEPARTMENT = new PRO_DOCS.DAL.Database.ARCHIVE_DEPARTMENT();
            CURRENT_SELECTED_ARCHIVE_DEPARTMENTS_FOLDERS_STRUCTURE = new PRO_DOCS.DAL.Database.ARCHIVE_DEPARTMENTS_FOLDERS_STRUCTURE();
        }
        private void treeList1_FocusedNodeChanged(object sender, DevExpress.XtraTreeList.FocusedNodeChangedEventArgs e)
        {
            RaiseDataSourceChanged(e.Node);
        }
        void RaiseDataSourceChanged(TreeListNode node)
        {
            if (!IS_FIRST_LOAD)
            {

                string nodeCation = GetNodeCaption(node);
                string nodeValue = node.GetValue(colData).ToString();
                object nodeTag = node.Tag;
                string nodeFolder = node.GetValue(colFolder).ToString();

                CURRENT_SELECTED_ApplicationStructureType = (node.Level.Equals(0)) ? ApplicationStructureTypes.Department : (ApplicationStructureTypes)node.GetValue(colType);// (ApplicationStructureTypes)Convert.ToInt32(node.GetValue(colType).ToString());

                switch (CURRENT_SELECTED_ApplicationStructureType)
                {
                    case ApplicationStructureTypes.Department:
                        {
                            btnAddSubFolder.Enabled = false;
                            btnSave.Enabled = false;
                            btnDelete.Enabled = false;

                            txtFolderName.Text = string.Empty;
                        }
                        break;
                    case ApplicationStructureTypes.New_Folder:
                        {
                            CURRENT_SELECTED_ARCHIVE_DEPARTMENTS_FOLDERS_STRUCTURE = (PRO_DOCS.DAL.Database.ARCHIVE_DEPARTMENTS_FOLDERS_STRUCTURE)nodeTag;
                            btnAddSubFolder.Enabled = false;
                            btnSave.Enabled = true;

                            btnDelete.Enabled = true;

                            txtFolderName.Text = CURRENT_SELECTED_ARCHIVE_DEPARTMENTS_FOLDERS_STRUCTURE.ARCHIVE_ARCHIVE_DEPARTMENTS_FOLDERS_STRUCTURE_NAME;
                            chkIsVisible.Checked = !CURRENT_SELECTED_ARCHIVE_DEPARTMENTS_FOLDERS_STRUCTURE.IS_DELETED.Value;
                        } break;
                    case ApplicationStructureTypes.Folder:
                        {
                            CURRENT_SELECTED_ARCHIVE_DEPARTMENTS_FOLDERS_STRUCTURE = (PRO_DOCS.DAL.Database.ARCHIVE_DEPARTMENTS_FOLDERS_STRUCTURE)nodeTag;
                            btnAddSubFolder.Enabled = true;
                            btnSave.Enabled = true;

                            btnDelete.Enabled = true;

                            txtFolderName.Text = CURRENT_SELECTED_ARCHIVE_DEPARTMENTS_FOLDERS_STRUCTURE.ARCHIVE_ARCHIVE_DEPARTMENTS_FOLDERS_STRUCTURE_NAME;
                            chkIsVisible.Checked = !CURRENT_SELECTED_ARCHIVE_DEPARTMENTS_FOLDERS_STRUCTURE.IS_DELETED.Value;
                        } break;

                }

            }
        }
        string GetNodeCaption(TreeListNode node)
        {
            string ret = string.Format("{0}", node.GetValue(colName));
            while (node.ParentNode != null)
            {
                node = node.ParentNode;
                ret = string.Format("{0} - {1}", node.GetValue(colName), ret);
            }
            return ret;
        }

        static bool AllowControlTextColor
        {
            get
            {
                return DevExpress.LookAndFeel.UserLookAndFeel.Default.ActiveSkinName != "Glass Oceans";
            }
        }
        internal void RefreshTreeList()
        {
            trvDepartmentFolderStructure.LayoutChanged();
        }

        internal void UpdateTreeViewMessages()
        {
            //CreateMessagesList(treeList1.Nodes);
            //RefreshTreeList();
            //RaiseDataSourceChanged(treeList1.FocusedNode);
        }

        public void BUILD_ARCHIVE_DEPARTMENT_FOLDER_STRUCTURE()
        {
            try
            {
                trvDepartmentFolderStructure.Nodes.Clear();

                List<PRO_DOCS.DAL.Database.ARCHIVE_DEPARTMENT> aRCHIVE_DEPARTMENTS = PRO_DOCSDatabaseDataContext.ARCHIVE_DEPARTMENTs.ToList();
                for (int i = 0; i < aRCHIVE_DEPARTMENTS.Count; i++)
                {
                    BUILD_ARCHIVE_DEPARTMENT_FOLDER_STRUCTURE(aRCHIVE_DEPARTMENTS[i]);
                }
            }
            catch (Exception ex)
            {
                string abc = ex.Message;
            }

        }

        private void BUILD_ARCHIVE_DEPARTMENT_FOLDER_STRUCTURE_FOLDERS_SUBFOLDERS(PRO_DOCS.DAL.Database.ARCHIVE_DEPARTMENTS_FOLDERS_STRUCTURE aRCHIVE_DEPARTMENTS_FOLDERS_STRUCTURE, TreeListNode trParentNode)
        {

            List<PRO_DOCS.DAL.Database.ARCHIVE_DEPARTMENTS_FOLDERS_STRUCTURE> aRCHIVE_DEPARTMENTS_FOLDERS_STRUCTURES = aRCHIVE_DEPARTMENTS_FOLDERS_STRUCTURE.ARCHIVE_DEPARTMENTS_FOLDERS_STRUCTUREs.ToList();

            for (int i = 0; i < aRCHIVE_DEPARTMENTS_FOLDERS_STRUCTURES.Count; i++)
            {
                PRO_DOCS.DAL.Database.ARCHIVE_DEPARTMENTS_FOLDERS_STRUCTURE _aRCHIVE_DEPARTMENTS_FOLDERS_STRUCTURE = aRCHIVE_DEPARTMENTS_FOLDERS_STRUCTURES[i];
                TreeListNode tlFolderNode = trvDepartmentFolderStructure.AppendNode(new object[] { _aRCHIVE_DEPARTMENTS_FOLDERS_STRUCTURE.ARCHIVE_ARCHIVE_DEPARTMENTS_FOLDERS_STRUCTURE_NAME, ApplicationStructureTypes.Folder, FolderTypes.Folder, 10, _aRCHIVE_DEPARTMENTS_FOLDERS_STRUCTURE.ARCHIVE_DEPARTMENTS_FOLDERS_STRUCTURE_ID }, trParentNode, _aRCHIVE_DEPARTMENTS_FOLDERS_STRUCTURE);

                BUILD_ARCHIVE_DEPARTMENT_FOLDER_STRUCTURE_FOLDERS_SUBFOLDERS(_aRCHIVE_DEPARTMENTS_FOLDERS_STRUCTURE, tlFolderNode);

            }
        }

        public void BUILD_ARCHIVE_DEPARTMENT_FOLDER_STRUCTURE(PRO_DOCS.DAL.Database.ARCHIVE_DEPARTMENT aRCHIVE_DEPARTMENT)
        {
            IS_FIRST_LOAD = true;
            CURRENT_SELECTED_ARCHIVE_DEPARTMENT = aRCHIVE_DEPARTMENT;

            trvDepartmentFolderStructure.Nodes.Clear();

            TreeListNode tlnDepartmentNode = trvDepartmentFolderStructure.AppendNode(new object[] { CURRENT_SELECTED_ARCHIVE_DEPARTMENT.ARCHIVE_DEPARTMENT_NAME, ApplicationStructureTypes.Department, FolderTypes.Folder, 12, CURRENT_SELECTED_ARCHIVE_DEPARTMENT.ARCHIVE_DEPARTMENT_ID }, null, CURRENT_SELECTED_ARCHIVE_DEPARTMENT);

            {
                //Gets the 1st Level
                List<PRO_DOCS.DAL.Database.ARCHIVE_DEPARTMENTS_FOLDERS_STRUCTURE> aRCHIVE_DEPARTMENTS_FOLDERS_STRUCTURES = CURRENT_SELECTED_ARCHIVE_DEPARTMENT.ARCHIVE_DEPARTMENTS_FOLDERS_STRUCTUREs.ToList();


                for (int i = 0; i < aRCHIVE_DEPARTMENTS_FOLDERS_STRUCTURES.Count; i++)
                {
                    PRO_DOCS.DAL.Database.ARCHIVE_DEPARTMENTS_FOLDERS_STRUCTURE aRCHIVE_DEPARTMENTS_FOLDERS_STRUCTURE = aRCHIVE_DEPARTMENTS_FOLDERS_STRUCTURES[i];

                    if (aRCHIVE_DEPARTMENTS_FOLDERS_STRUCTURE.PARENT_ARCHIVE_DEPARTMENTS_FOLDERS_STRUCTURE_ID.Value.Equals(Guid.Empty))
                    {
                        TreeListNode tlFolderNode = trvDepartmentFolderStructure.AppendNode(new object[] { aRCHIVE_DEPARTMENTS_FOLDERS_STRUCTURE.ARCHIVE_ARCHIVE_DEPARTMENTS_FOLDERS_STRUCTURE_NAME, ApplicationStructureTypes.Folder, FolderTypes.Folder, 10, aRCHIVE_DEPARTMENTS_FOLDERS_STRUCTURE.ARCHIVE_DEPARTMENTS_FOLDERS_STRUCTURE_ID }, tlnDepartmentNode, aRCHIVE_DEPARTMENTS_FOLDERS_STRUCTURE);


                        BUILD_ARCHIVE_DEPARTMENT_FOLDER_STRUCTURE_FOLDERS_SUBFOLDERS(aRCHIVE_DEPARTMENTS_FOLDERS_STRUCTURE, tlFolderNode);

                    }
                }

            }

            trvDepartmentFolderStructure.ExpandAll();
            IS_FIRST_LOAD = false;
        }

        private void trvDepartmentFolderStructure_AfterCollapse(object sender, NodeEventArgs e)
        {
            TreeListNode current_selected_node = e.Node;
            string node_type = current_selected_node.GetValue(colType).ToString();
            if (node_type.Equals(ApplicationStructureTypes.Folder.ToString()))
            {

                current_selected_node.SetValue(colImageIndex, 10);
            }
            if (node_type.Equals(ApplicationStructureTypes.New_Folder.ToString()))
            {

                current_selected_node.SetValue(colImageIndex, 13);
            }
        }

        private void trvDepartmentFolderStructure_AfterExpand(object sender, NodeEventArgs e)
        {
            TreeListNode current_selected_node = e.Node;
            string node_type = current_selected_node.GetValue(colType).ToString();
            if (node_type.Equals(ApplicationStructureTypes.Folder.ToString()))
            {
                current_selected_node.SetValue(colImageIndex, 11);
            }
            if (node_type.Equals(ApplicationStructureTypes.New_Folder.ToString()))
            {

                current_selected_node.SetValue(colImageIndex, 13);
            }
        }


        private void ucFolderStructureTree_Load(object sender, EventArgs e)
        {


            //BUILD_ARCHIVE_DEPARTMENT_FOLDER_STRUCTURE();


        }

        void DisableEnableIconsForNewAdd(bool enable)
        {
            btnAddSubFolder.Enabled = enable;
            btnAdParentFolder.Enabled = enable;
        }

        private void btnAdParentFolder_Click(object sender, EventArgs e)
        {
            DAL.Database.ARCHIVE_DEPARTMENTS_FOLDERS_STRUCTURE cURRENT_SELECTED_ARCHIVE_DEPARTMENTS_FOLDERS_STRUCTURE = new DAL.Database.ARCHIVE_DEPARTMENTS_FOLDERS_STRUCTURE();
            cURRENT_SELECTED_ARCHIVE_DEPARTMENTS_FOLDERS_STRUCTURE.ARCHIVE_DEPARTMENTS_FOLDERS_STRUCTURE_ID = Guid.Empty;
            cURRENT_SELECTED_ARCHIVE_DEPARTMENTS_FOLDERS_STRUCTURE.ARCHIVE_DEPARTMENT_ID = CURRENT_SELECTED_ARCHIVE_DEPARTMENT.ARCHIVE_DEPARTMENT_ID;
            cURRENT_SELECTED_ARCHIVE_DEPARTMENTS_FOLDERS_STRUCTURE.ARCHIVE_ARCHIVE_DEPARTMENTS_FOLDERS_STRUCTURE_NAME = "<NEW PARENT FOLDER>";
            cURRENT_SELECTED_ARCHIVE_DEPARTMENTS_FOLDERS_STRUCTURE.PARENT_ARCHIVE_DEPARTMENTS_FOLDERS_STRUCTURE_ID = Guid.Empty;
            cURRENT_SELECTED_ARCHIVE_DEPARTMENTS_FOLDERS_STRUCTURE.IS_DELETED = false;

            TreeListNode tlFolderNode = trvDepartmentFolderStructure.AppendNode(new object[] { cURRENT_SELECTED_ARCHIVE_DEPARTMENTS_FOLDERS_STRUCTURE.ARCHIVE_ARCHIVE_DEPARTMENTS_FOLDERS_STRUCTURE_NAME, ApplicationStructureTypes.New_Folder, FolderTypes.Folder, 13, cURRENT_SELECTED_ARCHIVE_DEPARTMENTS_FOLDERS_STRUCTURE.ARCHIVE_DEPARTMENTS_FOLDERS_STRUCTURE_ID }, trvDepartmentFolderStructure.Nodes[0], cURRENT_SELECTED_ARCHIVE_DEPARTMENTS_FOLDERS_STRUCTURE);
            DisableEnableIconsForNewAdd(false);
            tlFolderNode.Selected = true;
        }

        private void btnAddSubFolder_Click(object sender, EventArgs e)
        {
            TreeListNode current_selected_node = trvDepartmentFolderStructure.Selection[0];

            DAL.Database.ARCHIVE_DEPARTMENTS_FOLDERS_STRUCTURE cURRENT_SELECTED_ARCHIVE_DEPARTMENTS_FOLDERS_STRUCTURE = new DAL.Database.ARCHIVE_DEPARTMENTS_FOLDERS_STRUCTURE();
            cURRENT_SELECTED_ARCHIVE_DEPARTMENTS_FOLDERS_STRUCTURE.ARCHIVE_DEPARTMENTS_FOLDERS_STRUCTURE_ID = Guid.Empty;
            cURRENT_SELECTED_ARCHIVE_DEPARTMENTS_FOLDERS_STRUCTURE.ARCHIVE_DEPARTMENT_ID = CURRENT_SELECTED_ARCHIVE_DEPARTMENT.ARCHIVE_DEPARTMENT_ID;
            cURRENT_SELECTED_ARCHIVE_DEPARTMENTS_FOLDERS_STRUCTURE.ARCHIVE_ARCHIVE_DEPARTMENTS_FOLDERS_STRUCTURE_NAME = "<NEW SUB FOLDER>";
            cURRENT_SELECTED_ARCHIVE_DEPARTMENTS_FOLDERS_STRUCTURE.PARENT_ARCHIVE_DEPARTMENTS_FOLDERS_STRUCTURE_ID = CURRENT_SELECTED_ARCHIVE_DEPARTMENTS_FOLDERS_STRUCTURE.ARCHIVE_DEPARTMENTS_FOLDERS_STRUCTURE_ID;
            cURRENT_SELECTED_ARCHIVE_DEPARTMENTS_FOLDERS_STRUCTURE.IS_DELETED = false;

            TreeListNode tlFolderNode = trvDepartmentFolderStructure.AppendNode(new object[] { cURRENT_SELECTED_ARCHIVE_DEPARTMENTS_FOLDERS_STRUCTURE.ARCHIVE_ARCHIVE_DEPARTMENTS_FOLDERS_STRUCTURE_NAME, ApplicationStructureTypes.New_Folder, FolderTypes.Folder, 13, cURRENT_SELECTED_ARCHIVE_DEPARTMENTS_FOLDERS_STRUCTURE.ARCHIVE_DEPARTMENTS_FOLDERS_STRUCTURE_ID }, current_selected_node, cURRENT_SELECTED_ARCHIVE_DEPARTMENTS_FOLDERS_STRUCTURE);

            tlFolderNode.Selected = true;
            DisableEnableIconsForNewAdd(false);
            current_selected_node.ExpandAll();
        }

        private void btnSave_Click(object sender, EventArgs e)
        {
            SAVE_FOLDER_STRUCTURE();
        }

        private void SAVE_FOLDER_STRUCTURE()
        {
            dxErrorProvider1.ClearErrors();
            if (!string.IsNullOrEmpty(txtFolderName.Text))
            {

                Guid current_folder_id = Guid.NewGuid();
                if (CURRENT_SELECTED_ARCHIVE_DEPARTMENTS_FOLDERS_STRUCTURE.ARCHIVE_DEPARTMENTS_FOLDERS_STRUCTURE_ID.Equals(Guid.Empty))//new one
                {
                    PRO_DOCSDatabaseDataContext.proc_ARCHIVE_DEPARTMENTS_FOLDERS_STRUCTUREInsert
                        (current_folder_id,
                        CURRENT_SELECTED_ARCHIVE_DEPARTMENT.ARCHIVE_DEPARTMENT_ID,
                        CURRENT_SELECTED_ARCHIVE_DEPARTMENTS_FOLDERS_STRUCTURE.PARENT_ARCHIVE_DEPARTMENTS_FOLDERS_STRUCTURE_ID.Value,
                        txtFolderName.Text,
                        !chkIsVisible.Checked);

                }
                else
                {
                    current_folder_id = CURRENT_SELECTED_ARCHIVE_DEPARTMENTS_FOLDERS_STRUCTURE.ARCHIVE_DEPARTMENTS_FOLDERS_STRUCTURE_ID;

                    PRO_DOCSDatabaseDataContext.proc_ARCHIVE_DEPARTMENTS_FOLDERS_STRUCTUREUpdate
                        (current_folder_id,
                        CURRENT_SELECTED_ARCHIVE_DEPARTMENT.ARCHIVE_DEPARTMENT_ID,
                        CURRENT_SELECTED_ARCHIVE_DEPARTMENTS_FOLDERS_STRUCTURE.PARENT_ARCHIVE_DEPARTMENTS_FOLDERS_STRUCTURE_ID.Value,
                        txtFolderName.Text,
                        !chkIsVisible.Checked);
                }

                SAVE_FOLDER_STRUCTURE_PERMISSIONS(current_folder_id);

                CURRENT_SELECTED_ARCHIVE_DEPARTMENTS_FOLDERS_STRUCTURE = (from folder in PRO_DOCSDatabaseDataContext.ARCHIVE_DEPARTMENTS_FOLDERS_STRUCTUREs
                                                                          where folder.ARCHIVE_DEPARTMENTS_FOLDERS_STRUCTURE_ID.Equals(current_folder_id)
                                                                          select folder).FirstOrDefault();
                trvDepartmentFolderStructure.Selection[0].SetValue(colName, txtFolderName.Text);
                trvDepartmentFolderStructure.Selection[0].SetValue(colImageIndex, 10);
                trvDepartmentFolderStructure.Selection[0].SetValue(colType, ApplicationStructureTypes.Folder);
                trvDepartmentFolderStructure.Selection[0].SetValue(colData, CURRENT_SELECTED_ARCHIVE_DEPARTMENTS_FOLDERS_STRUCTURE.ARCHIVE_DEPARTMENTS_FOLDERS_STRUCTURE_ID.ToString());
                trvDepartmentFolderStructure.Selection[0].Tag = CURRENT_SELECTED_ARCHIVE_DEPARTMENTS_FOLDERS_STRUCTURE;

                DisableEnableIconsForNewAdd(true);
            }
            else
            {
                dxErrorProvider1.SetError(txtFolderName, BLL.WIN.Properties.ErrorProviderMessages.Default.InputLeftBlank.Replace("{name}", "Folder name"));
            }
        }

        private void SAVE_FOLDER_STRUCTURE_PERMISSIONS(Guid current_folder_id)
        {
            //SAVE PERMITTED USER ROLES
            ucPermittedUserRoles1.SAVE_PERMITTED_USER_ROLES(0, current_folder_id, 0);
            //SAVE DENIED USER ROLES
            ucDeniedUserRoles1.SAVE_DENIED_USER_ROLES(0, current_folder_id);
            //SAVE PERMITTED LOGIN USER
            ucPermittedLoginUsers1.SAVE_PERMITTED_LOGIN_USERS(0, current_folder_id, 0);
            //SAVE DENIED LOGIN USER
            ucDeniedLoginUsers1.SAVE_DENIED_LOGIN_USERS(0, current_folder_id, 0);
        }

        private void btnDelete_Click(object sender, EventArgs e)
        {
            if (!CURRENT_SELECTED_ARCHIVE_DEPARTMENTS_FOLDERS_STRUCTURE.ARCHIVE_DEPARTMENTS_FOLDERS_STRUCTURE_ID.Equals(Guid.Empty))//new one
            {
                //1. delete from the database
                PRO_DOCSDatabaseDataContext.proc_ARCHIVE_DEPARTMENTS_FOLDERS_STRUCTUREDelete
                    (CURRENT_SELECTED_ARCHIVE_DEPARTMENTS_FOLDERS_STRUCTURE.ARCHIVE_DEPARTMENTS_FOLDERS_STRUCTURE_ID);
            }
            //2. remove from the tree
            CURRENT_SELECTED_ARCHIVE_DEPARTMENTS_FOLDERS_STRUCTURE = new DAL.Database.ARCHIVE_DEPARTMENTS_FOLDERS_STRUCTURE();
            trvDepartmentFolderStructure.DeleteSelectedNodes();
            DisableEnableIconsForNewAdd(true);

        }

        private void txtFolderName_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == Convert.ToChar(Keys.Enter))
            {
                SAVE_FOLDER_STRUCTURE();
            }
        }

        private void btnSynchroniseFolderStructure_Click(object sender, EventArgs e)
        {
            if (new SynchroniseFolders(SynchroniseFolders.FoldersSynchronisingOptions.IMPORT).ShowDialog().Equals(DialogResult.OK))
            {

            }
        }

        private void btnExportFolderStructure_Click(object sender, EventArgs e)
        {
            if (new SynchroniseFolders(SynchroniseFolders.FoldersSynchronisingOptions.EXPORT).ShowDialog().Equals(DialogResult.OK))
            {

            }
        }
    }
}
